#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tornado
import tornado.web
try:
    import ujson as json
except:
    import json
from controls import data_feedback_mysql


class BaseHandler(tornado.web.RequestHandler):
    def get_current_user(self):
        return self.get_secure_cookie("username")

class ListFeedbackHandler(BaseHandler):
    def post(self, *args, **kwargs):
        begin = self.get_argument('begin')
        limit = self.get_argument('limit')

        feedback_list = data_feedback_mysql.get_feedback(begin, limit)

        if feedback_list:
            res = {'ret':0, 'msg':'ok', 'res':feedback_list}
            self.write(json.dumps(res))
            return
        else:
            res = {'ret':1, 'msg':'获取用户反馈失败'}
            self.write(json.dumps(res))
            return